<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<%@ include file="/include/taglibs.jsp" %>
<%
    String pid = request.getParameter("pid");

    User user1 = (User) SecurityUtils.getSubject().getPrincipal();
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <!-- HTTP 1.1 -->
    <meta http-equiv="pragma" content="no-cache,no-store">
    <!-- HTTP 1.0 -->
    <meta http-equiv="cache-control" content="no-cache,no-store">
    <!-- Prevent caching at the proxy server -->
    <meta http-equiv="expires" content="0">
    <title>"科学"号线上运行管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <%@ include file="/include/base_styles.jsp" %>
    <script src="${ctx}/assets/admin/pagejs/common.js"></script>
    <style>
        .btn.btn-app.btn-xs {
            width: 64px;
            font-size: 15px;
            border-radius: 8px;
            padding-bottom: 7px;
            padding-top: 8px;
            line-height: 1.45;
        }

        .btn.btn-app.btn-xs {
            width: 64px;
            font-size: 15px;
            border-radius: 8px;
            padding-bottom: 7px;
            padding-top: 8px;
            line-height: 1.45;
        }
    </style>
</head>
<body class="no-skin">
<!-- 上面导航栏开始 -->
<%@ include file="/include/top.jsp" %>
<!-- 上面导航栏结束 -->
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
        var _base = "${base}";
    </script>

    <!-- #section:basics/sidebar -->
    <div id="sidebar" class="sidebar responsive">
        <script type="text/javascript">
            try {
                ace.settings.check('sidebar', 'fixed')
            } catch (e) {
            }
        </script>
        <!-- 左边导航栏 -->
        <%--<%@ include file="/include/left2.jsp"%>--%>
        <jsp:include page="/include/left.jsp">
            <jsp:param name="pid" value="<%=pid%>"/>
        </jsp:include>
        <!-- 左边导航栏结束 -->

        <!-- #section:basics/sidebar.layout.minimize -->
        <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
            <i class="ace-icon fa fa-angle-double-left white" data-icon1="ace-icon fa fa-angle-double-left"
               data-icon2="ace-icon fa fa-angle-double-right" id="firstdenglu" style="background-color:#585858"></i>
        </div>
        <!-- /section:basics/sidebar.layout.minimize -->
        <script type="text/javascript">
            try {
                ace.settings.check('sidebar', 'collapsed')
            } catch (e) {
            }
        </script>
    </div>

    <!-- top2开始 -->
    <jsp:include page="/include/pagecontent.jsp">
        <jsp:param name="pid" value="<%=pid%>"/>
    </jsp:include>
    <div class="ace-settings-container" id="ace-settings-container">
        <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
            <i class="ace-icon menu-icon fa fa-cog bigger-150 white"></i>
        </div>

        <div class="ace-settings-box" id="ace-settings-box">
            <div>
                <div class="pull-left">
                    <select id="skin-colorpicker" class="hide">
                        <option data-skin="no-skin" value="#438EB9">#438EB9</option>
                        <option data-skin="skin-1" value="#222A2D">#222A2D</option>
                        <option data-skin="skin-2" value="#C6487E">#C6487E</option>
                        <option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
                    </select>
                </div>
                <span>&nbsp; 选择皮肤</span>
            </div>
            <div style="height:10px;width:100%;"></div>
            <%--<div>
                <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar" />
                <label class="lbl" for="ace-settings-navbar"> 固定导航条</label>
            </div>

            <div>
                <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar" />
                <label class="lbl" for="ace-settings-sidebar"> 固定滑动条</label>
            </div>

            <div>
                <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs" />
                <label class="lbl" for="ace-settings-breadcrumbs">固定面包屑</label>
            </div>

            <div>
                <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl" />
                <label class="lbl" for="ace-settings-rtl">切换到左边</label>
            </div>--%>

            <div>
                <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container"/>
                <label class="lbl" for="ace-settings-add-container">
                    切换窄屏
                    <b></b>
                </label>
            </div>
        </div>
    </div>

    <!-- top2结束 -->
    <script type="text/javascript">
        //Load content via ajax
        var back_url = [];//存放点击历史的数组
        ace.load_ajax_scripts([null], function () {
            jQuery(function ($) {
                //消息提醒的函数调用
                //间隔15秒
                var newdate = new Date();
                newdate = newdate.getTime();
                $('input, textarea').placeholder();

                $(function () {
                    $(".tooltip-primary").tooltip();
                });
                if ('enable_ajax_content' in ace) {
                    var options = {
                        content_url: function (url) {
                            //返回上页的url
                            back_url.push(document.location.href);
                            if (back_url.length > 20) {
                                back_url = back_url.slice(back_url.length - 19, back_url.length);
                            }
                            var path = document.location.href;
                            var path2 = path.split("#")[1];
                            var path3 = path.split("#")[1].split("?").length;
                            if (path3 > 1) {

                                return path.split("#")[1].split("?")[0];
//											+ ".action?"
//											+ path.split("#")[1].split("?")[1]; //+ url.replace(/\//, "=");
                            } else {
                                return path2;
                            }
                        }
                        , default_url: '#index'
                    }
                    ace.enable_ajax_content($, options);
                }
            });
            /* //自动完成分类框
             $("#nav-search-input1").catcomplete({//获取分类自动完成的方法
             type : "post",
             delay : 0,//输入之后出现自动完成框的延时时间
             source : "
            ${base}system/backend_page!getConleSearch.action",//加载的数据
             select : function(event, ui) {
             //location = encodeURI(encodeURI(ui.item.url));
             location = ui.item.url;
             }
             });
             $("#nav-search-input1").blur(function(){
             $("#nav-search-input1").val("");
             }); */

            $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
                if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                    setTimeout(function () {
                        $(".grid-table").jqGrid('setGridWidth', $(".grid-table").closest('[class*="col-"]').width());
                    }, 0);
                }
            });

        });

    </script>
    <!--修改个人资料弹窗-->
    <div id="fastEditDialog" tabindex="-1" class="modal  fade" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog my-dialog-5" id="addfastclass">
            <div class="modal-content">
                <div class="my-dialog-header-1">
                    <i class="ace-icon  fa fa-check"></i>修改密码
                    <button type="button" class="close my-close" data-dismiss="modal" aria-label="Close">
                        <i class="fa fa-times"></i>
                    </button>
                </div>
                <div class="modal-body" data-spy="scroll">
                    <div id="fastEditDiv">
                        <form id="editPwdForm">
                            <table>
                                <tr>
                                    <td>原密码</td>
                                    <td><input type="password" name="oldPwd"/></td>
                                </tr>
                                <tr>
                                    <td>新密码</td>
                                    <td><input type="password" name="newPwd"/></td>
                                </tr>
                                <tr>
                                    <td>确认新密码</td>
                                    <td><input type="password" name="confirmNewPwd"/></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <div class="modal-footer   my-dialog-footer">
                    <button type="button" class="btn btn-primary" onclick="pfastEditOk()">确认</button>
                    <button type="button" class="btn " data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>

    <!--修改个人资料弹窗-->
    <div id="fastEditDialogP" tabindex="-1" class="modal  fade" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog my-dialog-5" id="addfastclassP">
            <div class="modal-content">
                <div class="my-dialog-header-1">
                    <i class="ace -icon  fa fa-check"></i>个人信息
                    <button type="button" class="close my-close" data-dismiss="modal" aria-label="Close">
                        <i class="fa fa-times"></i>
                    </button>
                </div>
                <div class="modal-body" data-spy="scroll">
                    <div id="fastEditDivP">
                        <form id="peditPwdFormP">
                            <table>
                                <tr>
                                    <td>用户编号：</td>
                                    <td id="username"><%=user.getUsername()%></td>
                                </tr>
                                <tr>
                                    <td>用户姓名：</td>
                                    <td>
                                        <input type="text" id="name" name="name"/>
                                    </td>

                                </tr>
                                <tr>
                                <td>用户性别：</td>
                                <td>
                                     <select type="text" id="gender" name="gender"/>
                                </td>
                                <tr/>
                                <tr>
                                    <td>证件类型:</td>
                                    <td >
                                        <select name="certificateType" id="certificateType" title="">
                                            <option value="-1">请选择</option>
                                        </select>
                                    </td>
                                </tr>
                               <%-- <tr>
                                    <td>证件号：</td>
                                    <td>
                                        <input type="text" id="certificateNum" name="certificateNum"/>

                                    </td>
                                </tr>--%>
                                <tr>
                                    <td>单位：</td>
                                    <td> <input type="text" id="company" name="company"/></td>
                                </tr>
                                <tr>
                                    <td>单位性质1：</td>
                                    <td>
                                        <select id="companyType1" name="companyType1"> </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>单位性质2：</td>
                                    <td>
                                        <select id="companyType2" name="companyType2"></select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>所属部门：</td>
                                    <td><input type="text" id="department" name="department"/></td>
                                </tr>

                                <tr>
                                    <td>职称：</td>
                                    <td >
                                        <input type="text" id="zhiCheng" name="zhiCheng"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>电子邮件：</td>
                                    <td >
                                        <input type="text" id="email" name="email"/>
                                    </td>
                                </tr>
                                   <tr>
                                       <td>移动电话:</td>
                                       <td> <input id="mobile" name="mobile" type="text"/></td>
                                   </tr>

                            </table>
                        </form>
                    </div>
                </div>
                <div class="modal-footer   my-dialog-footer">
                    <button type="button" class="btn btn-primary" onclick="fastEditOk()">确认</button>
                    <button type="button" class="btn " data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 提示信息 -->
    <div id="alertstopt" tabindex="-1" class="modal fade" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog  my-dialog-1">
            <div class="modal-content  ">
                <div class="my-dialog-header-1">
                    <i class="ace -icon  fa fa-check"></i> 提示
                    <button type="button" class="close   my-close" data-dismiss="modal"
                            aria-label="Close">
                        <i class="fa fa-times"></i>
                    </button>
                </div>
                <div class="modal-body  my-dialog-body" data-spy="scroll">
                    <i class="ace-icon fa fa-hand-o-right blue bigger-120"></i><span
                        id="tishitopt"></span>
                </div>
                <div class="modal-footer   my-dialog-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">确认</button>
                </div>
            </div>
        </div>
    </div>
    <script type="application/javascript">
        $(function () {
            loadUserGenderItems();
            loadCertificateType();
            loadCompanyType1();
            loadCompanyType2();
            fillForm();
        })


        function fillForm() {
            $('#username').val('<%=user.getUsername()%>}').attr('disabled', true);
            $('#name').val('<%=user.getName()%>');
            $('#gender').val('<%=user.getGender()%>');
            $('#certificateType').val('<%=user.getCertificateType()%>');//证件类型
            $('#email').val('<%=user.getEmail()%>');
           // $('#certificateNum').val('<%=user.getCertificateNum()%>');//证件号
            $('#company').val('<%=user.getCompany()%>');//单位
            $('#mobile').val('<%=user.getMobile()%>');
            $('#companyType1').val('<%=user.getCompanyType1()%>');//单位性质1
            $('#companyType2').val('<%=user.getCompanyType2()%>');//单位性质1
            $('#department').val('<%=user.getDepartment()%>');//所属部门
            $('#zhiCheng').val('<%=user.getZhiCheng()%>');
        }
        function fastEditOk() {
            $('#peditPwdFormP').ajaxSubmit({
                url: "${ctx}/${frameworkPath}/user/edit/<%=user.getUsername()%>",
                type: "post",
                async: false,
                traditional: true,
                dataType: 'json',
                data: {username: '<%=user.getUsername()%>'},
                success: function (message) {
                    if (message.success) {
                        $("#fastEditDialogP").modal('hide');
                        lui.success("修改个人信息成功");
                    }
                    else {
                        lui.fail('修改个人信息失败');
                    }
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('修改个人信息失败');
                }
            });
        }
        function pfastEditOk() {
            $('#editPwdForm').ajaxSubmit({
                url: "${ctx}/${frameworkPath}/user/changePassword",
                type: "post",
                async: false,
                traditional: true,
                dataType: 'json',
                data: {username: '<%=user.getUsername()%>'},
                success: function (message) {
                    if (message.success) {
                        $("#fastEditDialog").modal('hide');
                        lui.success("修改密码成功");
                    }
                    else {
                        lui.fail('修改密码失败');
                    }
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('修改密码失败');
                }
            });
        }


        //从数据字典中加载用户性别
        function loadUserGenderItems() {
            $.ajax({
                type: 'GET',
                url: '${ctx}/${frameworkPath}/item/USER_GENDER/sub',
                async: false,
                dataType: 'json',
                success: function (data) {
                    var tempAjax = "";
                    $.each(data, function (idx, item) {
                        tempAjax += "<option value='" + item.value + "'>" + item.name + "</option>";
                    })
                    $("#gender").empty();
                    $("#gender").append(tempAjax);
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('加载数据失败！');
                }
            });
        }
        //加载证件类型
        function loadCertificateType() {
            $.ajax({
                type: 'GET',
                url: '${ctx}/${frameworkPath}/item/Certificate_Type/sub',
                async: false,
                dataType: 'json',
                success: function (data) {
                    var tempAjax = "";
                    $.each(data, function (idx, item) {
                        tempAjax += "<option value='" + item.value + "'>" + item.name + "</option>";
                    });
                    $("#certificateType").empty();
                    $("#certificateType").html(tempAjax);
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('加载数据失败！');
                }
            });
        }

        //加载单位性质1类型
        function loadCompanyType1() {
            $.ajax({
                type: 'GET',
                url: '${ctx}/${frameworkPath}/item/Company_Type1/sub',
                async: false,
                dataType: 'json',
                success: function (data) {
                    var tempAjax = "";
                    $.each(data, function (idx, item) {
                        tempAjax += "<option value='" + item.value + "'>" + item.name + "</option>";
                    });
                    $("#companyType1").empty();
                    $("#companyType1").html(tempAjax);
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('加载数据失败！');
                }
            });
        }

        //加载单位性质2类型
        function loadCompanyType2() {
            $.ajax({
                type: 'GET',
                url: '${ctx}/${frameworkPath}/item/Company_Type2/sub',
                async: false,
                dataType: 'json',
                success: function (data) {
                    var tempAjax = "";
                    $.each(data, function (idx, item) {
                        tempAjax += "<option value='" + item.value + "'>" + item.name + "</option>";
                    });
                    $("#companyType2").empty();
                    $("#companyType2").html(tempAjax);
                },
                error: function (XmlHttpRequest, textStatus, errorThrown) {
                    lui.fail('加载数据失败！');
                }
            });
        }
    </script>
</body>
</html>
